package com.music.wangyi

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.Toolbar
import androidx.lifecycle.ViewModelProvider
import androidx.navigation.findNavController
import androidx.navigation.ui.AppBarConfiguration
import androidx.navigation.ui.setupWithNavController
import com.music.wangyi.model.LoginModel
import kotlinx.android.synthetic.main.activity_main.*

val noToolBarShow = arrayOf("fragment_splash","登录")

class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        ViewModelProvider(this).get(LoginModel::class.java)

        val navController = findNavController(R.id.nav_host_fragment)
        navController.addOnDestinationChangedListener { _, destination, _ ->

            if(noToolBarShow.indexOf(destination.label) != -1) {
                tool_bar.visibility = View.GONE
            } else {
                tool_bar.visibility = View.VISIBLE
            }

        }
        val appBarConfiguration = AppBarConfiguration(navController.graph)
        tool_bar.setupWithNavController(navController, appBarConfiguration)

    }
}
